package com.lcx.plugin.ui;

import com.intellij.openapi.options.Configurable;
import com.lcx.plugin.dto.MySettingsStorageDTO;
import com.lcx.plugin.service.MySettingsStorageService;
import org.jetbrains.annotations.Nullable;

/**
 * @author lcx
 * @version 1.0.0
 * @since 2021/08/07 19:42
 */
public interface MyBaseSettings extends Configurable {
    /**
     * 帮助提示信息
     *
     * @return 提示信息
     */
    @Nullable
    @Override
    default String getHelpTopic() {
        return getDisplayName();
    }

    /**
     * 重置设置，重置到上次持久化之前的状态
     */
    @Override
    default void reset() {
        loadSettingsStore();
    }

    /**
     * 获取设置信息
     *
     * @return 获取设置信息
     */
    default MySettingsStorageDTO getSettingsStorage() {
        return MySettingsStorageService.getSettingsStorage();
    }

    /**
     * 加载配置信息
     */
    default void loadSettingsStore() {
        this.loadSettingsStore(getSettingsStorage());
    }

    /**
     * 加载配置信息
     *
     * @param settingsStorage 配置信息
     */
    void loadSettingsStore(MySettingsStorageDTO settingsStorage);

}
